package com.pfzy.lib.sdk.log;

import com.tencent.mars.xlog.Log;

public final class AndroidLog implements Log.LogImp {
    public static void print(int priority, String tag, String msg) {
        String substring;
        if (msg == null) {
            msg = "";
        }
        if (tag == null) {
            tag = "";
        }

        for (int i = 0; i < msg.length();i+=2000){
            if (msg.length() <= i) {
                substring = msg.substring(i);
            } else {
                substring = msg.substring(i, i);
            }
            println(priority, tag, substring);
        }
    }

    private static void println(int priority, String tag, String msg) {
        try {
            if (!UXLog.mDebug) {
                return;
            }
            android.util.Log.println(priority, tag, msg);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void appenderClose() {
    }

    @Override
    public void appenderFlush(long logInstancePtr, boolean isSync) {
    }

    @Override
    public void appenderOpen(int level, int mode, String cacheDir, String logDir, String nameprefix, int cacheDays) {
    }

    @Override
    public int getLogLevel(long logInstancePtr) {
        return 0;
    }

    @Override
    public long getXlogInstance(String nameprefix) {
        return 0L;
    }

    @Override
    public void logD(long logInstancePtr, String tag, String filename, String funcname, int linuxTid, int pid, long tid, long maintid, String log) {
        print(android.util.Log.DEBUG, tag, log);
    }

    @Override
    public void logE(long logInstancePtr, String tag, String filename, String funcname, int linuxTid, int pid, long tid, long maintid, String log) {
        print(android.util.Log.ERROR, tag, log);
    }

    @Override
    public void logF(long logInstancePtr, String tag, String filename, String funcname, int linuxTid, int pid, long tid, long maintid, String log) {
        print(android.util.Log.DEBUG, tag, log);
    }

    @Override
    public void logI(long logInstancePtr, String tag, String filename, String funcname, int linuxTid, int pid, long tid, long maintid, String log) {
        print(android.util.Log.INFO, tag, log);
    }

    @Override
    public void logV(long logInstancePtr, String tag, String filename, String funcname, int linuxTid, int pid, long tid, long maintid, String log) {
        print(android.util.Log.VERBOSE, tag, log);
    }

    @Override
    public void logW(long logInstancePtr, String tag, String filename, String funcname, int linuxTid, int pid, long tid, long maintid, String log) {
        print(android.util.Log.WARN, tag, log);
    }

    @Override
    public long openLogInstance(int level, int mode, String cacheDir, String logDir, String nameprefix, int cacheDays) {
        return 0L;
    }

    @Override
    public void releaseXlogInstance(String nameprefix) {
    }

    @Override
    public void setAppenderMode(long logInstancePtr, int mode) {
    }

    @Override
    public void setConsoleLogOpen(long logInstancePtr, boolean isOpen) {
    }

    @Override
    public void setMaxAliveTime(long logInstancePtr, long aliveSeconds) {
    }

    @Override
    public void setMaxFileSize(long logInstancePtr, long aliveSeconds) {
    }
}
